class SessionsController < ApplicationController
  before_filter :logado?, :except => :create
  
  def create
    funcionario = Funcionario.authenticate(params[:login], params[:password])
    if funcionario
      session[:funcionario_id] = funcionario.id
      redirect_to funcionarios_path, :notice => "Logged in!"
    else
      redirect_to root_path
      flash.now.alert = "Invalid login or password"
    end
  end
  
  
  def destroy
  session[:funcionario_id] = nil
  redirect_to root_url, :notice => "Logged out!"
  end

end
